home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / snip9503 / ord_text.c < prev    next >
C/C++ Source or Header  |  1995-03-14  |  673b  |  35 lines

  1. /*
  2. **  Originally published as part of the MicroFirm Function Library
  3. **
  4. **  Copyright 1991, Robert B.Stout
  5. **
  6. **  Subset version with modifications suggested by Maynard Hogg
  7. **  released to the public domain, 1992
  8. **
  9. **  Function to return ordinal text.
  10. */
  11.  
  12. static char *text[] = {"th", "st", "nd", "rd"};
  13.  
  14. char *ordinal_text(int number)
  15. {
  16.       if (((number %= 100) > 9 && number < 20) || (number %= 10) > 3)
  17.             number = 0;
  18.       return text[number];
  19. }
  20.  
  21. #ifdef TEST
  22.  
  23. #include <stdio.h>
  24.  
  25. main()
  26. {
  27.       int i;
  28.  
  29.       for (i = 0; i < 26; ++i)
  30.             printf("%d%s\n", i, ordinal_text(i));
  31.       return 0;
  32. }
  33.  
  34. #endif /* TEST */
  35.